package com.sg.service.biz.bff.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.BffQueryActualValueDataDetailReqDto;
import com.sg.dto.biz.bff.req.BffQueryRightCycleActualValueDataDetailReqDto;
import com.sg.dto.biz.bff.res.BffQueryActualValueDataDetailRespDto;
import com.sg.dto.biz.bff.res.BffQueryRightCycleActualValueDataDetailRespDto;
import com.sg.dto.integration.calc.QueryRightCycleActualValueDataDetailComReqDto;
import com.sg.dto.integration.calc.QueryRightCycleActualValueDataDetailComRespDto;
import com.sg.dto.integration.calc.QueryStandardDataDetailComReqDto;
import com.sg.dto.integration.calc.QueryStandardDataDetailComRespDto;
import com.sg.service.biz.bff.StandardDataService;
import com.sg.common.exception.Assert;
import com.wicket.okrcalc.integration.StandardDataService;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class StandardDataServiceImpl implements StandardDataService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    com.sg.service.biz.calc.StandardDataService fwCalcStandardDataClient;

    /**
     * B3-查询向右周期实际值[7278]
     * gen by moon at 7/3/2023, 3:49:13 AM
     */
    @Trace(operationName = "B3-查询向右周期实际值")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryRightCycleActualValueDataDetailRespDto queryRightCycleActualValueDataDetail(BffQueryRightCycleActualValueDataDetailReqDto reqDto) {


        QueryRightCycleActualValueDataDetailComRespDto queryRightCycleActualValueDataDetailComRespDto_1 = null;
//步骤0: D4-查询向右周期实际值详情(公共) - queryRightCycleActualValueDataDetailCom
        QueryRightCycleActualValueDataDetailComRespDto queryRightCycleActualValueDataDetailComRespDto = null;
        QueryRightCycleActualValueDataDetailComReqDto queryRightCycleActualValueDataDetailComReqDto = new QueryRightCycleActualValueDataDetailComReqDto();
        if (reqDto != null) {
            queryRightCycleActualValueDataDetailComReqDto.setEvaObjTargetCycleId(reqDto.getEvaObjTargetCycleId());//SimpleFieldAssign//sourceId:1074150_1
            queryRightCycleActualValueDataDetailComReqDto.setCycleId(reqDto.getCycleId());//SimpleFieldAssign//sourceId:1074151_1
            queryRightCycleActualValueDataDetailComReqDto.setTargetCycleContentId(reqDto.getTargetCycleContentId());//SimpleFieldAssign//sourceId:1074153_1
            queryRightCycleActualValueDataDetailComReqDto.setTargetCycleContentTypeCode(reqDto.getTargetCycleContentTypeCode());//SimpleFieldAssign//sourceId:1074154_1
            queryRightCycleActualValueDataDetailComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1074155_1
        }

        /*D4-查询向右周期实际值详情(公共)[7279]   */
        Assert.isNull(queryRightCycleActualValueDataDetailComReqDto.getEvaObjTargetCycleId(), "B3-查询向右周期实际值-D4-查询向右周期实际值详情(公共)-被评对象目标周期ID不能为空", false);
        Assert.isNull(queryRightCycleActualValueDataDetailComReqDto.getCycleId(), "B3-查询向右周期实际值-D4-查询向右周期实际值详情(公共)-周期ID不能为空", false);
        Assert.isNull(queryRightCycleActualValueDataDetailComReqDto.getTargetCycleContentId(), "B3-查询向右周期实际值-D4-查询向右周期实际值详情(公共)-关联目标内容ID不能为空", false);
        Assert.isNull(queryRightCycleActualValueDataDetailComReqDto.getTargetCycleContentTypeCode(), "B3-查询向右周期实际值-D4-查询向右周期实际值详情(公共)-关联目标内容类型编码不能为空", false);
        Assert.isNull(queryRightCycleActualValueDataDetailComReqDto.getEvaluationTemplateId(), "B3-查询向右周期实际值-D4-查询向右周期实际值详情(公共)-冗余评价模板ID不能为空", false);
        queryRightCycleActualValueDataDetailComRespDto = fwCalcStandardDataClient.queryRightCycleActualValueDataDetailCom(queryRightCycleActualValueDataDetailComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryRightCycleActualValueDataDetailComRespDto_1 = queryRightCycleActualValueDataDetailComRespDto;

        BffQueryRightCycleActualValueDataDetailRespDto retData = new BffQueryRightCycleActualValueDataDetailRespDto();
        if (queryRightCycleActualValueDataDetailComRespDto_1 != null) {
            retData.setDataResultId(queryRightCycleActualValueDataDetailComRespDto_1.getDataResultId());//SimpleFieldAssign//sourceId:1074164_1
            retData.setDataResult(queryRightCycleActualValueDataDetailComRespDto_1.getDataResult());//SimpleFieldAssign//sourceId:1074165_1
        }


        return retData;
    }

    /**
     * B4-查询实际值标准数据详情[7275]
     * gen by moon at 7/5/2023, 1:37:22 AM
     */
    @Trace(operationName = "B4-查询实际值标准数据详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryActualValueDataDetailRespDto queryActualValueDataDetail(BffQueryActualValueDataDetailReqDto reqDto) {


        QueryStandardDataDetailComRespDto queryStandardDataDetailComRespDto_1 = null;
//步骤0: D4-1查标准数据详情(公共) - queryStandardDataDetailCom
        QueryStandardDataDetailComRespDto queryStandardDataDetailComRespDto = null;
        QueryStandardDataDetailComReqDto queryStandardDataDetailComReqDto = new QueryStandardDataDetailComReqDto();
        queryStandardDataDetailComReqDto.setDataType("ACTUAL_VALUE");//sourceId:1072610_1
        queryStandardDataDetailComReqDto.setDataUsageSceneCode("TARGET_PLAN_CALC_DATA_STATISTICS");//sourceId:1077350_1
        queryStandardDataDetailComReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:1072611_1
        queryStandardDataDetailComReqDto.setIsNewData("TRUE");//sourceId:1072612_1
        queryStandardDataDetailComReqDto.setIsUpdateCycleNewData("TRUE");//sourceId:1072616_1
        if (reqDto != null) {
            queryStandardDataDetailComReqDto.setEntityId(reqDto.getEntityId());//SimpleFieldAssign//sourceId:1072609_1
            queryStandardDataDetailComReqDto.setPeriodId(reqDto.getPeriodId());//SimpleFieldAssign//sourceId:1072608_1
            queryStandardDataDetailComReqDto.setUpdateCycleId(reqDto.getUpdateCycleId());//SimpleFieldAssign//sourceId:1072617_1
            queryStandardDataDetailComReqDto.setThemeContentId(reqDto.getThemeContentId());//SimpleFieldAssign//sourceId:1072613_1
        }

        /*D4-1查标准数据详情(公共)[2695]   */
        Assert.isNull(queryStandardDataDetailComReqDto.getEntityId(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-归属内容表主键ID不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getPeriodId(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-周期ID不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getUpdateCycleId(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-更新周期ID不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getDataType(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-数据类型编码不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getDataUsageSceneCode(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-数据使用场景编码不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getSubjectLifeCycle(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-主体生命周期不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getIsNewData(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-是否归属周期最新数据不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getIsUpdateCycleNewData(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-是否更新周期最新数据不能为空", false);
        Assert.isNull(queryStandardDataDetailComReqDto.getThemeContentId(), "B4-查询实际值标准数据详情-D4-1查标准数据详情(公共)-主题内容ID不能为空", false);
        queryStandardDataDetailComRespDto = fwCalcStandardDataClient.queryStandardDataDetailCom(queryStandardDataDetailComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;


        queryStandardDataDetailComRespDto_1 = queryStandardDataDetailComRespDto;

        BffQueryActualValueDataDetailRespDto retData = new BffQueryActualValueDataDetailRespDto();
        if (queryStandardDataDetailComRespDto_1 != null) {
            retData.setDataResultId(queryStandardDataDetailComRespDto_1.getDataResultId());//SimpleFieldAssign//sourceId:1072618_1
            retData.setDataResult(queryStandardDataDetailComRespDto_1.getDataResult());//SimpleFieldAssign//sourceId:1072619_1
        }


        return retData;
    }
    //
}
